package com.madmart.gil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class OpenedClass extends Activity implements OnClickListener, OnCheckedChangeListener{

	TextView question, test;
	Button returnData;
	RadioGroup selectionList;
	String paoRecebido, setData;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.send);
		initialize();
//		Bundle cestaRecebida = getIntent().getExtras();
//		paoRecebido = cestaRecebida.getString("chave");	
//		question.setText(paoRecebido);
		
	}
	
	private void initialize(){
		question = (TextView)findViewById(R.id.tvQuestion);
		test = (TextView)findViewById(R.id.tvText);
		returnData = (Button)findViewById(R.id.bReturn);
		returnData.setOnClickListener(this);
		selectionList = ( RadioGroup ) findViewById(R.id.rgAnswers);
		selectionList.setOnCheckedChangeListener(this);
	}

	@Override
	public void onClick(View v) {
	
		Intent pessoaIntent = new Intent();
		Bundle mochila = new Bundle();
		mochila.putString("resposta", setData);
		pessoaIntent.putExtras(mochila);
		setResult(RESULT_OK, pessoaIntent);
		finish();
		
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch(checkedId){
		case R.id.rCrazy:
			setData = "Provavelmente está certo...";
			break;	
		
		case R.id.rSexy:
			setData = "Definitivamente está certo...";
			break;
		case R.id.rBoth:
			setData = "Se liga!";
		}
		test.setText(setData);
	}

}
